package com.longZ.himalaya.utils;

import com.longZ.himalaya.base.BaseFragment;
import com.longZ.himalaya.fragments.HistoryFragment;
import com.longZ.himalaya.fragments.RecommendFragment;
import com.longZ.himalaya.fragments.SubscriptionFragment;

import java.util.HashMap;
import java.util.Map;

public class FragmentCreator extends Constants {
    private static Map<Integer, BaseFragment> sCreator = new HashMap<>();

    public  static BaseFragment getFragment(int index) {
        BaseFragment baseFragment = sCreator.get(index);
        if (baseFragment != null) {
            return baseFragment;
        }
        switch (index) {
            case Constants.INDEX_RECOMMEND:
                baseFragment = new RecommendFragment();
                break;
            case Constants.INDEX_SUBSCRIPTION:
                baseFragment = new SubscriptionFragment();
                break;
                case Constants.INDEX_HISTORY:
                    baseFragment = new HistoryFragment();
                    break;
        }
        sCreator.put(index, baseFragment);
        return baseFragment;
    }
}
